<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chk = new CheckMode_3d($curruser['acl'], 3, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$show5N = getShow35($gametype);
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
if ($curruser['acl'] != 255)
{
    $userlist = GetUserList($curruser['id']);
    if ($userlist == "")
    {
        $ui->showErrorPage("<p>还没有建立会员！</p>");
        exit();
    }
}
require( "class_3d/RateConfig_3d.php" );
require( "class_3d/SRate_3d.php" );
$RateConfig_3d = new RateConfig_3d($gametype);
switch ($show3D3S)
{
    case 0 :
        $SRate_3d = new SRate_3d($gametype);
        $startbet_3d = $conf->get("startbet_{$tbl}");
        $stopbet_3d = $conf->get("stopbet_{$tbl}");
        if ($stopbet_3d == "0000")
        {
            $stopbet_3d = "2359";
        }
        break;
    case 1 :
        $SRate_3d = new SRate_3s($gametype);
        unset($RateConfig_3d->playtypeArr02['r1pass']);
        break;
}
$disk = getvar("disk");
$order = getvar("order");
$playtype = getvar("playtype");
$id = getvar("id");
$bid = getvar("bid");
if ($id == "")
{
    $showday = date("Y-m-d");
    $lottoData = $SRate_3d->getLotto3DByDate($showday);
}
else
{
    $id = intval($id);
    $lottoData = $SRate_3d->getLotto3DById($id);
    $showday = $lottoData['open'];
}
if ($lottoData == "")
{
    $ui->showErrorPage("目前没有{$tblName}可以下注期数！", true);
    exit();
}
else if ($show3D3S == 1)
{
    $startbet_3d = date("Hi", strtotime($lottoData['startbet']));
    $stopbet_3d = date("Hi", strtotime($lottoData['stopbet']));
    if ($stopbet_3d == "0000")
    {
        $stopbet_3d = "2359";
    }
    $showday = date("Y-m-d", strtotime($lottoData['openbet']));
}
$disk = isset($RateConfig_3d->diskArr[$disk]) ? $disk : "1";
$order = isset($RateConfig_3d->orderArr[$order]) ? $order : 0;
$playtype = isset($RateConfig_3d->playtypeArr02[$playtype]) ? $playtype : "r1";
if ($bid != "")
{
    $fieldsArr = array($bid);
}
else
{
    $fieldsArr = $RateConfig_3d->playGroupArr02[$playtype];
}
$bidstr = "";
if ($bid == "")
{
    $bidstr = "";
}
else
{
    $bid == intval($bid);
    if (!in_array($bid, $RateConfig_3d->playGroupArr02[$playtype]))
    {
        diemsg("{$tblName}玩法资料错误。");
    }
    $bidstr = "&bid=" . $bid;
    $tpl->set("bid", $bid);
}
if ($show5N)
{
    $jsFuname = "_n5";
    $jsFunameFlag = "true";
}
else
{
    $jsFuname = "";
    $jsFunameFlag = "false";
}
$menu_list_url = "";
$tempUrl = "op.php?op=agent&fp=onlinebet_3d&id=" . $lottoData['id'] . "&gametype={$gametype}&playtype=";
$tempArr = array();
if ($g_5number_3d)
{
    $jsFuname = "_n5";
}
else
{
    $jsFuname = "";
}
$RateConfig_3d->playtypeArr02['r1all'] = "全部";
foreach ($RateConfig_3d->playtypeArr02 as $key => $val)
{
    $showUrl = $tempUrl . $key;
    if ($playtype == $key)
    {
        $tempClass = " class=\"cbig\"";
    }
    else
    {
        $tempClass = "";
    }
    $tempArr[] = "<th {$tempClass} id='myThBar{$key}' ><a href=\"javascript:clickTitle('{$key}');\">{$val}</a><br />(<span style='color:#cc0000' id='spanPageAmount{$key}'></span>)</th>";
}
$menu_list_url = implode("", $tempArr);
switch ($show3D3S)
{
    case 0 :
        $stopbet_3d = $conf->get("stopbet_{$tbl}");
        if ($stopbet_3d == "0000")
        {
            $stopbet_3d = "2359";
        }
        $tempStrInt = false;
        break;
    case 1 :
        $tempStrInt = strtotime($lottoData['stopbet']);
        break;
}
$preArr = $SRate_3d->getLotto3DByIdPre($lottoData['id']);
$nextArr = $SRate_3d->getLotto3DByIdNext($lottoData['id']);

if ($preArr)
{
    $strPre = "<a href=\"op.php?op=agent&fp=onlinebet_3d&id=" . $preArr['id'] . "&gametype={$gametype}&playtype={$playtype}\">&lt&lt&lt上一期</a>";
}
else
{
    $strPre = "";
}
if ($nextArr)
{
    $strNext = "<a id='next_a' href=\"op.php?op=agent&fp=onlinebet_3d&id=" . $nextArr['id'] . "&gametype={$gametype}&playtype={$playtype}\">下一期&gt&gt&gt</a>";
}
else
{
    $strNext = "";
}
unset($preArr);
unset($nextArr);
$h = substr($stopbet_3d, 0, 2);
$m = substr($stopbet_3d, 2);
$tempStr = "{$showday} {$h}:{$m}:00";
$timetamp = systime();
$timetamplimit = strtotime($tempStr) - $timetamp;
$tpl->load("main", "onlinebet_3d.htm");
$tpl->set(array("playtype" => $RateConfig_3d->playtypeArr02[$playtype], "menu_list_url" => $menu_list_url, "lotto_id_3d" => $lottoData['id'], "round" => $lottoData['round'], "open" => $lottoData['open'], "strPre" => $strPre, "strNext" => $strNext, "timetamp" => $timetamp, "timetamplimit" => $timetamplimit, "playtypestr" => $playtype, "gametype" => $gametype, "gametypeStr" => $tblName, "jsLang" => $g_conf['language'], "jsFuname" => $jsFuname));
$jslink = "<script src=\"js_3d/js3d.js\"></script>\n";
$jslink .= "<script src=\"js_3d/showRateRecord.js\"></script>\n";
$jslink .= "<script>\r\nvar __roundID = " . $lottoData['id'] . ";\r\nvar __reloadCK = 0;\r\nvar now = new Date(1000 * {$timetamp});\r\nvar timestap = {$timetamplimit};\r\nvar myGlobalVal = {};\r\nmyGlobalVal.gametype = '{$gametype}';\r\nmyGlobalVal.lotto_id_3d = " . $lottoData['id'] . ";\r\nmyGlobalVal.playtypestr = '{$playtype}';\r\nmyGlobalVal.open = '" . $lottoData['open'] . "';\r\nmyGlobalVal.reloadCK = '10';\r\nmyGlobalVal.jsFuname = {$jsFunameFlag};\r\nvar _playtype = 'r1';\r\nvar _myHeader = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';\r\nvar _myHeader2 = '<thead><tr class=\"td6\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';\r\nvar _myHeader3 = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';\r\n</script>\r\n";
$ui->set("jslink", $jslink);
$ui->header();
$tpl->show("main");
$ui->footer();
?>